<template>
  <div>
    <van-tabbar v-model="active">
      <van-tabbar-item icon="home-o" to="/">首页</van-tabbar-item>
      <van-tabbar-item icon="user-o" to="/mine">我的</van-tabbar-item>

    </van-tabbar>
  </div>
</template>

<script>
export default {
  name: "tabbar",
  data() {
    return {
      active: 0,
    };
  },
  mounted() {
    /* 直接在tabbar组件页面监听，判断当前页面是哪个页面,
    解决刷新时,tab默认为 0 的bug */


    if (this.$route.name === 'Home' || this.$route.path === '/') {
      console.log("000")
      this.active = 0
    } else if (this.$route.name === 'Mine') {
      console.log("1")
      this.active = 1
    }


  },

}
</script>

<style scoped>

</style>
